/*
 * @Description:AES加密
 * @Autor: YSKM
 * @Date: 2023-06-08 14:30:00
 */
// import { AES, mode, pad, enc } from 'crypto-ts'
import CryptoJS from 'crypto-js'
import Keys from '@/constant/key'

export default class VAES {
    static encrypt(text: string | null): string | null {
        // crypto-ts 加密
        // return AES.encrypt(text ?? '', Keys.aseKey, { mode: mode.ECB, padding: pad.PKCS7 }).toString()
        // crypto-js 加密
        return CryptoJS.AES.encrypt(text, Keys.aseKey, {
            mode: CryptoJS.mode.ECB,
            padding: CryptoJS.pad.Pkcs7
        }).toString()
        // return text;
    }

    static decrypt(text: string | null): string | null {
        // crypto-ts 解密
        // return AES.decrypt(text ?? '', Keys.aseKey, { mode: mode.ECB, padding: pad.PKCS7 }).toString(enc.Utf8)
        // crypto-js 解密
        return CryptoJS.AES.decrypt(text, Keys.aseKey, {
            mode: CryptoJS.mode.ECB,
            padding: CryptoJS.pad.Pkcs7
        }).toString(CryptoJS.enc.Utf8)
        // return text;
    }
}
